#ifndef SNAKEWIDGET_H
#define SNAKEWIDGET_H
// #define private public

#include <QWidget>
#include <QVector>
#include <QQueue>
#include <QTimer>

class SnakeWidget : public QWidget
{
    Q_OBJECT
public:
    explicit SnakeWidget(QWidget *parent = 0);
    ~SnakeWidget();
    void replay();
    void makeFail();

signals:

public slots:
    void timeout();

protected:
    void paintEvent(QPaintEvent * event);
    void keyPressEvent(QKeyEvent *event);

private:
    void genFood();

    QTimer timer;

    enum Dot {
        Empty, Snake, Food, Wall
    };
    Dot * *snakeMap;
    enum Dir {
        Left = 0, Down = 1, Right = 2, Up = 3
    };
    Dir dir;

    QQueue<QPoint> snakeQueue;
    int cntWidth;
    int cntHeight;
    int cntFoods;
    int lenInitSnake;
};

#endif // SNAKEWIDGET_H
